<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ modCount }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: current === '全部' }"
          @click="change('全部')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: current === '未完成' }"
          @click="change('未完成')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: current === '已完成' }"
          @click="change('已完成')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button @click="$emit('clearDone')" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ["count", 'list','status'],
  data() {
    return {
      current: "全部",
    };
  },
  methods:{
    change(status){
      this.current = status;
      this.$emit('status', status); 
    }
  },
  computed: {
    modCount(){
      let count = 0;
      this.list.forEach(item =>{
        if(!item.isDone){
        count++;
      }
      })
      return count;
    }
  }
};
</script>